﻿var sparrow = {
	config : {
		domain : "zhuaququ.com",
		websitName : "抓蛐蛐儿",
		resource : "http://r.zhuaququ.net",
		includeVirtualPath : false
	}
};

var Namespace = new Object();
Namespace.register = function(path) {
	var arr = path.split(".");
	var ns = "";
	for ( var i = 0; i < arr.length; i++) {
		if (i > 0)
			ns += ".";
		ns += arr[i];
		eval("if(typeof(" + ns + ") == 'undefined') " + ns + " = new Object();");
	}
};

/** ************************js基础库提供所有web项目使用**************************** */
/*
 * 1、浏览器相关 2、document方法简化 3、字符串与数组系统函数扩展 4、AJAX方法封装类 5、鼠标相关 6、file文件操作 7、表单验证
 * document.onkeydown =function (e) {
 * 
 * if (event.keyCode == 13 && event.ctrlKey) { onCtrlEnterKeyPress(); } else if
 * (event.keyCode == 13) { onEnterKeyPress(); } };
 */
var pathName = window.location.pathname == "/" ? ""
		: ("/" + window.location.pathname.split('/')[1]);
var rootPath = window.location.protocol + "//" + window.location.host
		+ (sparrow.config.includeVirtualPath ? pathName : "");
var resource = sparrow.config.resource;
var websitName = sparrow.config.websitName;
var defaultHeadIcoUrl = resource + "/system/user.png";
var defaultForumIcoUrl = resource + "/system/forum.gif";
var cssText = {
	menuFrameDiv : "background:#ffffff;position:absolute;z-index:1000;border:#ccc 1px solid;width:{0}px;height:auto;left:{1}px;top:{2}px;display:none",
	menuUl : "width:{0}px;height:auto;overflow:hidden;list-style:none;margin:0px;padding:0px;text-align:left",
	menuLi : "width:{0}px;overflow:hidden;line-height:20px;margin:0px;border-bottom:#ccc 1px dotted;cursor:pointer;"
};
var m = new Message("m");
/*----------------------------------浏览器相关---------------------------------------*/
var browser = {
	cookie : {
		permission : "permission",
		callBackUrl : "callBackUrl",
		// 配置cookie的域并非cookie的key
		domain : sparrow.config.domain
	},
	appName : function() {
		if (navigator.userAgent.search(/MSIE/img) != -1) {
			return "IE";
		} else if (navigator.userAgent.search(/Opera/img) != -1) {
			return "Opera";
		} else if (navigator.userAgent.search(/Firefox/img) != -1) {
			return "Firefox";
		} else if (navigator.userAgent.search(/Chrome/img) != -1) {
			return "Google";
		}
	},
	version : function() {
		if (navigator.userAgent.search(/MSIE/img) != -1) {
			navigator.userAgent.match(/MSIE\b\s*([0-9\.0-9]+);/img);
			return RegExp.$1;
		} else if (navigator.userAgent.search(/Opera/img) != -1) {
			navigator.userAgent.match(/Version\/([0-9\.]+)/img);
			return RegExp.$1;
		} else if (navigator.userAgent.search(/Firefox/img) != -1) {
			navigator.userAgent.match(/Firefox\/([0-9\.]+)/img);
			return RegExp.$1;
		} else if (navigator.userAgent.search(/Chrome/img) != -1) {
			navigator.userAgent.search(/Chrome\/([0-9\.]+)/img);
			return RegExp.$1;
		}
	},
	addFavorite : function(url, title) {
		if (document.all) {
			window.external.AddFavorite(url, title);
		} else if (window.sidebar) {
			window.sidebar.addPanel(title, url, "");
		} else {
			alert("对不起，您的浏览器不支持此操作!\n请您使用菜单栏或Ctrl+D收藏本站。");
		}
	},
	setHome : function(anchorLabel, url) {
		try {
			anchorLabel.style.behavior = 'url(#default#homepage)';
			anchorLabel.setHomePage(url);
		} catch (e) {
			if (window.netscape) {
				try {
					netscape.security.PrivilegeManager
							.enablePrivilege("UniversalXPConnect");
					var prefs = Components.classes['@mozilla.org/preferences-service;1']
							.getService(Components.interfaces.nsIPrefBranch);
					prefs.setCharPref('browser.startup.homepage', url);
				} catch (e) {
					alert('抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。');
				}
			}
		}
	},
	copy : function(text, msg) {
		try {
			if (window.clipboardData) {
				window.clipboardData.setData("Text", text);
				alert(msg);
			} else if (window.netscape) {
				try {
					netscape.security.PrivilegeManager
							.enablePrivilege("UniversalXPConnect");
				} catch (e) {
					alert("您的浏览器设置为不允许复制！\n如果需要此操作，请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true',再重试复制操作!");
					return false;
				}
				var clip = Components.classes['@mozilla.org/widget/clipboard;1']
						.createInstance(Components.interfaces.nsIClipboard);
				if (!clip)
					return;
				var trans = Components.classes['@mozilla.org/widget/transferable;1']
						.createInstance(Components.interfaces.nsITransferable);
				if (!trans) {
					return;
				}
				trans.addDataFlavor('text/unicode');
				var supportsString = Components.classes["@mozilla.org/supports-string;1"]
						.createInstance(Components.interfaces.nsISupportsString);
				supportsString.data = text;
				trans.setTransferData("text/unicode", supportsString, text
						.getByteLength());
				var clipid = Components.interfaces.nsIClipboard;
				if (!clip)
					return false;
				clip.setData(trans, null, clipid.kGlobalClipboard);
				alert(msg);
			}
		} catch (e) {
			alert("对不起！您的浏览器不支持该功能");
		}
	},
	setCookie : function(cookieName, cookieValue, expireseconds, domain, path,
			secure) {
		var expires = null;
		if (expireseconds != 0 && expireseconds) {
			var currentDate = new Date();

			expires = new Date();

			expires.setTime(currentDate.getTime() + expireseconds * 1000);
		}

		var documentCookie = (encodeURIComponent(cookieName) + '='
				+ encodeURIComponent(cookieValue)

				+ (expires ? '; expires=' + expires.toGMTString() : '')

				+ '; path=' + (path ? path : '/')

				+ '; domain=' + (domain ? domain : this.cookie.domain)

		+ (secure ? '; secure' : ''));
		document.cookie = documentCookie;

	},
	getCookie : function(cookieName) {
		var cookieValue = null;
		var posName = document.cookie.indexOf(escape(cookieName) + '=');
		if (posName != -1) {
			var posValue = posName + (escape(cookieName) + '=').length;
			var endPos = document.cookie.indexOf(';', posValue);
			if (endPos != -1)
				cookieValue = decodeURIComponent(document.cookie.substring(
						posValue, endPos));
			else
				cookieValue = decodeURIComponent(document.cookie
						.substring(posValue));
		}
		if (cookieValue == null || typeof (cookieValue) == "undefined"
				|| cookieValue == "undefined") {
			return null;
		}
		return cookieValue;
	},
	// 根据按下控件的对象获取要执行的按钮事件
	// auguments=window.dialogArguments子页获取参数
	showModalDialog : function(width, height, url, openbf, args) {
		var result;
		if (url.indexOf("?") != -1) {
			url += "&time=" + new Date();
		} else {
			url += "?time=" + new Date();
		}
		if (browser.appName() == "IE") {
			result = window.showModalDialog(url, args, "dialogHeight:" + height
					+ "px; dialogWidth:" + width
					+ "px; status:no; help:no; scroll:auto");
		} else {
			result = window
					.open(
							url,
							args,
							"height="
									+ height
									+ ", width="
									+ width
									+ ", toolbar= no, menubar=no, scrollbars=auto, resizable=no, location=no, status=no,top=100,left=300");
		}
		if (result) {
			openbf(result);
		}
	},
	showWindow : function(width, height, url, args, win) {
		if (url.indexOf("?") != -1) {
			url += "&t=" + Math.random();
		} else {
			url += "?t=" + Math.random();
		}
		if (!win) {
			win = window;
		}
		win
				.open(
						url,
						args,
						"height="
								+ height
								+ ",width="
								+ width
								+ ",toolbar= no, menubar=no, scrollbars=auto, resizable=no, location=no, status=no,top=100,left=300");
	},
	getCurrentUrlWithoutParameter : function() {
		var currentLocation = window.location.href;
		if (currentLocation.indexOf('?') > -1) {
			currentLocation = currentLocation.substring(0, currentLocation
					.indexOf('?'));
		}
		if (currentLocation.indexOf("#") > -1) {
			currentLocation = currentLocation.substring(0, currentLocation
					.indexOf('#'));
		}
		return currentLocation;
	},
	getUserId : function() {
		var permission = browser.getCookie(this.cookie.permission);
		if (permission == null) {
			return 0;
		}
		var userInfo = permission.split('&');
		return userInfo[0].substring("id=".length);
	},
	getUserName : function() {
		var permission = browser.getCookie(this.cookie.permission);
		if (permission == null) {
			return null;
		}
		var userInfo = permission.split('&');
		return userInfo[1].substring("name=".length);
	},
	isLogin : function() {
		var userId = browser.getUserId();
		if (userId == null || userId == 0 || userId == "0" || userId == "null"
				|| userId == "") {
			return false;
		} else {
			return true;
		}
	},
	// 获取**时间格式
	getBeforeTime : function(updateTime) {
		updateTime = (new Date(updateTime)).valueOf();
		var currentTime = new Date().valueOf();
		var beforeDateConfig = [ {
			name : "秒前",
			split : 60
		}, {
			name : "分钟前",
			split : 60
		}, {
			name : "小时前",
			split : 24
		}, {
			name : "天前",
			split : 30
		}, {
			name : "月前",
			split : 12
		}, {
			name : "年前",
			split : 100
		} ];
		return (function(timeSplit, depth) {
			if (timeSplit / beforeDateConfig[depth].split < 1) {
				// 本地时间与服务器时间不一致导致出现负数
				return (parseInt(timeSplit) < 0 ? 1 : parseInt(timeSplit))
						+ beforeDateConfig[depth].name;
			} else {
				return arguments.callee(timeSplit
						/ beforeDateConfig[depth].split, ++depth);
			}
		}((currentTime - updateTime) / 1000, 0));
	}
};

function setOpacity(obj, n) {
	// ie<10
	obj.style.filter = 'alpha(opacity=' + n + ')';
	// ie=10 firefox ...
	obj.style.opacity = n / 100;
}

function Request(name) {// 获取页面ID参数
	var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
	if (reg.test(location.href)) {
		return unescape(RegExp.$2.replace(/\+/g, " "));
	} else {
		return "";
	}
}

function doaction(action, formIndex) {
	formIndex = formIndex ? formIndex : 0;
	if (action) {
		document.forms[formIndex].action = action;
	}
	document.forms[formIndex].submit();
}

/*----------------------------------document方法简化----------------------------------------------*/
$Son = function(pNode, tagName) {
	var childs = new Array();
	var childIndex = 0;
	var allChilds = pNode.getElementsByTagName(tagName);
	if (tagName == "li") {
		pNode = allChilds[0].parentNode;
	}
	for ( var i = 0; i < allChilds.length; i += 1) {
		if (allChilds[i].parentNode == pNode) {
			childs[childIndex] = allChilds[i];
			childIndex += 1;
		}
	}
	return childs;
};
$tag = function(tagName) {
	return document.getElementsByTagName(tagName);
};
/*
 * 功能说明:等价于document.getElementById 参数：tagId标签名称 例子:("mydivid")
 */
$ = function(tagId) {
	return document.getElementById(tagId);
};
/*
 * 功能说明:等价于document.getElementsByName 参数：tagName标签名称 例子:("table")
 */
$name = function(tagName) {
	return document.getElementsByName(tagName);
};
/*
 * 功能说明:等价于document.createElement 参数：tagName标签名称 例子:c("table")
 */
$c = function(tagName) {
	return document.createElement(tagName);
};
$for = function(forId) {
	var labelList = document.getElementsByTagName("label");
	for ( var i = 0; i < labelList.length; i += 1) {
		if (labelList[i].attributes["for"].value == forId) {
			return labelList[i];
		}
	}
};
// 获取radio的选择值
$radioValue = function(radioName) {
	var radioList = $name(radioName);
	for ( var i = 0; i < radioList.length; i++) {
		if (radioList[i].checked) {
			return radioList[i].value;
		}
	}
	return "";
};
// 获取checkBox的选择值
$checkBoxValue = function(checkboxName, attribute) {
	var selectedTag = new Array();
	var tagArray = $name(checkboxName);
	// 获取当前已经选中的标签
	for ( var i = 0; i < tagArray.length; i++) {
		if (tagArray[i].checked) {
			if (attribute) {
				selectedTag.push(tagArray[i].attributes[attribute].value);
			} else {
				selectedTag.push(tagArray[i].value);
			}
		}
	}
	return selectedTag;
};
/*----------------------------------字符串与数组系统函数扩展----------------------*/

function StringBuffer() {
	this.string = new Array;
}
StringBuffer.prototype.append = function(str) {
	this.string.push(str);
};
StringBuffer.prototype.toString = function() {
	return this.string.join("");
};
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
String.prototype.ltrim = function() {
	return this.replace(/(^\s*)/g, "");
};
String.prototype.rtrim = function() {
	return this.replace(/(\s*$)/g, "");
};
// 如果为""或者是''则返回为null 所以在调用之前要做了null判断
String.prototype.toJson = function() {
	if (this == "" || this == "''") {
		return null;
	} else if (this.indexOf("error|") == -1) {
		try {
			return eval("("
					+ this.replace(/\r\n/g, "<br/>").replace(/\n/g, "<br/>")
					+ ")");
		} catch (err) {
			return null;
		}
	}
};
String.prototype.firstCharToAscii = function() {
	return this.charCodeAt(0);
};
String.prototype.leftAlignWithChar = function(c, length) {
	length = length ? length : 3;
	c = c ? c : '0';
	if (this.length < length) {
		var charArray = new Array();
		var charCount = length - this.length;
		for ( var i = 0; i < charCount; i++) {
			charArray.push(c);
		}
		return charArray.join("") + this;
	}
};
String.prototype.getCountByChar = function(c) {
	return this.split(c).length - 1;
};
String.prototype.getByteLength = function() {
	return this.replace(/[^\x00-\xff]/g, "**").length;
};
String.prototype.getCountOfChar = function(c) {
	return this.split(c).length - 1;
};
String.prototype.subString = function(len, hasDot) {
	var newLength = 0;
	var newStr = "";
	var chineseRegex = /[^\x00-\xff]/g;
	var singleChar = "";
	var strLength = this.replace(chineseRegex, "**").length;
	var i;
	for (i = 0; i < strLength; i += 1) {
		singleChar = this.charAt(i).toString();
		if (singleChar.match(chineseRegex)) {
			newLength += 2;
		} else {
			newLength += 1;
		}
		if (newLength > len) {
			break;
		}
		newStr += singleChar;
	}
	if (hasDot && strLength > len) {
		newStr += "..";
	}
	return newStr;
};
String.prototype.encodeSplitKey = function() {
	var str = this;
	str = str.replace(/#/g, "#limit");
	str = str.replace(/:/g, "#colon#");
	str = str.replace(/,/g, "#dot#");
	return str;
};
String.prototype.decodeSplitKey = function() {
	var str = this;
	str = str.replace(/#colon#/g, ":");
	str = str.replace(/#dot#/g, ",");
	str = str.replace(/#limit/g, "#");
	return str;
};
// 字符格式化方法
String.prototype.format = function() {
	var newStr = this;
	var reg = null;
	for ( var i = 0; i < arguments.length; i++) {
		reg = RegExp('\\{' + i + '\\}', 'gm');
		newStr = newStr.replace(reg, arguments[i]);
	}
	return newStr;
};
// 过滤闭合的thml标签
String.prototype.filterHTML = function() {
	var newString = this;
	while (newString.search(/<([a-z0-9]*?).*?>([\s\S]*?)<\/\1>/gi) > -1) {
		newString = newString.replace(/<([a-z0-9]*?).*?>([\s\S]*?)<\/\1>/gi,
				"$2");
	}
	if (newString.search(/<input.*>/)) {
		newString = newString.replace(/<input.*>/gi, "");
	}

	if (newString.search(/<(script).*?>.*?<\/\1>/)) {
		newString = newString.replace(/<(script).*?>.*?<\/\1>/gi, "");
	}
	if (newString.search(/<script.*>/)) {
		newString = newString.replace(/<script.*>/gi, "");
	}
	return newString;
};
Array.prototype.clear = function() {
	for ( var i = 0; i < this.length; i += 1) {
		this.pop();
	}
};
Array.prototype.indexOf = function(key) {
	for ( var i = 0; i < this.length; i++) {
		if (this[i] == key) {
			return i;
			break;
		}
	}
	return -1;
};
var $document = {
	handle : null,
	timer : null,
	ready : function() {
		$document.timer = window.setInterval("$document._start()", 5);
	},
	clause : null,
	_start : function() {
		if ($document.clause()) {
			window.clearInterval($document.timer);
			$document.handle();
		}
	}
};
var jevent = {
	getEvent : function(e) {
		return window.event || e;
	},
	getSrcElement : function(e) {
		e = jevent.getEvent(e);
		if (e)
			return e.srcElement || e.target;
		else
			return null;
	},
	cancelBubble : function(e) {
		window.event ? window.event.cancelBubble = true : e.stopPropagation();
	},
	// 要附加事件的控件
	// 事件全名onclick
	// 事件委托方法
	add : function(srcElement, eventName, eventHandle) {
		if (srcElement.attachEvent) {
			srcElement.attachEvent(eventName, eventHandle);
		} else {
			srcElement.addEventListener(eventName.substring(2), eventHandle,
					false);
		}
	}
};
/** *************js位置函数。注意如果控件被隐藏则位置获取时将为0******************** */
var position = {
	getAbsoluteTopPosByCtrl : function(ctrl) {
		var srcObj = typeof (ctrl) == "string" ? $(ctrl) : ctrl;
		var returnValue = srcObj.offsetTop;
		while ((srcObj = srcObj.offsetParent) != null) {
			returnValue += srcObj.offsetTop;
		}
		return returnValue;
	},
	getAbsoluteTopPosByEvent : function(e) {
		return e.pageY ? e.pageY
				: (e.clientY ? (e.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop
						: document.body.scrollTop))
						: null);
	},
	getAbsoluteLeftPosByCtrl : function(ctrl) {
		var srcObj = typeof (ctrl) == "string" ? $(ctrl) : ctrl;
		var returnValue = srcObj.offsetLeft;
		while ((srcObj = srcObj.offsetParent) != null) {
			returnValue += srcObj.offsetLeft;
		}
		return returnValue;
	},
	getAbsoluteLeftPosByEvent : function(e) {
		return e.pageX ? e.pageX
				: (e.clientX ? (e.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft
						: document.body.scrollLeft))
						: null);
	}
};
/*----------------------------------AJAX方法封装类-------------------------------------------------*/
/*
 * 功能说明:ajax类对象 成员说明： 内部对象:_objPool: xmlHttpRequest对象池 _getInstance:
 * 获得xmlHttpRequest对象方法 _createObj: 创建xmlHttpRequest对象方法 外部对象:srcElement 获取鼠标事件源
 * req请求服务方法 : 参数说明: getOrPost:get或post请求, url: 请求url responsef：请求回发处理函数
 * isay:是否异步 postStr：post请求的参数字符串
 * 
 */
var ajax = {
	_objPool : [],
	referWindow : window,
	url : null,
	isgoed : null,
	srcElement : null,
	OK : 'OK',
	FAIL : 'FAIL',
	EXIST : 'EXIST',
	_getInstance : function() {
		for ( var i = 0; i < this._objPool.length; i += 1) {
			if (this._objPool[i].readyState === 0
					|| this._objPool[i].readyState == 4) {
				return this._objPool[i];
			}
		}
		this._objPool[this._objPool.length] = this._createObj();
		return this._objPool[this._objPool.length - 1];
	},
	_createObj : function() {
		var http_request = null;
		if (window.XMLHttpRequest) {
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				http_request.overrideMimeType("text/xml");
			}
		} else {
			if (window.ActiveXObject) {
				try {
					http_request = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						http_request = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
					}
				}
			}
		}
		if (http_request === null) {
			window.alert("浏览器不支持AJAX,请设置浏览器安全级别或更新浏览器");
		}
		return http_request;
	},
	gourl : function(url) {
		ajax.referWindow.location.href = url;
	},
	req : function(getOrPost, url, responsef, isay, postStr, srcElement) {
		var objXMLHttp = this._getInstance();
		if (srcElement) {
			this.srcElement = srcElement;
		}
		with (objXMLHttp) {
			try {
				if (isay == undefined || isay == null) {
					isay = true;
				}
				open(getOrPost, url, isay);
				if (getOrPost == "GET") {
					send(null);
				} else {
					if (postStr != null) {
						objXMLHttp.setRequestHeader("Content-Length",
								postStr.length);
						// encodeURIComponent编码
						objXMLHttp
								.setRequestHeader("Content-Type",
										"application/x-www-form-urlencoded;charset=utf-8");
					}
					send(postStr);
				}
				onreadystatechange = function() {
					// alert("状态信息"+objXMLHttp.readyState);
					if (objXMLHttp.readyState == 4) {
						// alert("结果状态"+objXMLHttp.status);
						if (objXMLHttp.status == 200) {
							if (objXMLHttp.responseText.indexOf("nologin") != -1) {
								showLogin();
							} else if (objXMLHttp.responseText
									.indexOf("Access Denied") != -1) {
								if (!system.accessDenied)
									system.accessDenied = "Access Denied";
								jalert(system.accessDenied, "sad");
							} else if (responsef) {
								// $("divTest").innerHTML+=url+postStr+responsef+objXMLHttp.responseText;
								responsef(objXMLHttp);
							}
						} else {
							if (objXMLHttp.status == 404) {
								alert("\u8d44\u6e90\u672a\u627e\u5230....");// 资源未找到
							} else {
								if (objXMLHttp.status == 500) {
									alert("\u670d\u52a1\u5668\u9519\u8bef");// 服务器错误
								} else {
									if (objXMLHttp.status == 12031) {
										alert("\u670d\u52a1\u5668\u672a\u542f\u52a8");// 服务器未启动
									} else {
										alert("\u672a\u77e5\u9519\u8bef");// 未知错误
									}
								}
							}
						}
					}
				};
			} catch (e) {
				alert(e);
			}
		}
	}
};
// ----------------------------------鼠标相关----------------------------------------//
var mouse = {
	dragapproved : false,
	srcElement : null,
	eventX : null,
	eventY : null,
	srcLeftPos : null,
	srcRightPos : null,
	over : function(obj) {
		mouse.c = obj.style.backgroundColor;
		obj.style.backgroundColor = "#e7effa";// "#F7FFFF";
	},
	out : function(obj) {
		obj.style.backgroundColor = mouse.c;
	},
	movef : function(e) {
		if (!e) {
			e = window.event;
		}
		if (mouse.dragapproved && mouse.srcElement != null) {
			mouse.srcElement.style.left = mouse.srcLeftPos + e.clientX
					- mouse.eventX;
			mouse.srcElement.style.top = mouse.srcRightPos + e.clientY
					- mouse.eventY;
		} else {
			return true;
		}
	},
	drags : function(e) {
		try {
			e = e || window.event;
			var srcElement = jevent.getSrcElement(e);
			if (srcElement.className.indexOf("drag") != -1) {
				if (srcElement.className == "drag-s") {
					mouse.srcElement = srcElement;
				} else if (srcElement.className == "drag-p") {
					mouse.srcElement = srcElement.parentNode;
				} else if (srcElement.className == "drag-pp") {
					mouse.srcElement = srcElement.parentNode.parentNode;
				} else {
					mouse.srcElement = null;
				}

				mouse.dragapproved = true;
				mouse.srcLeftPos = position
						.getAbsoluteLeftPosByCtrl(mouse.srcElement);
				mouse.srcRightPos = position
						.getAbsoluteTopPosByCtrl(mouse.srcElement);
				mouse.eventX = e.clientX;
				mouse.eventY = e.clientY;
				document.onmousemove = mouse.movef;
			} else {
				mouse.srcElement = null;
				document.onmousemove = null;
			}
		} catch (err) {
		}
	}
};
document.onmousedown = function(e) {
	mouse.drags(e);
};
document.onmouseup = function(e) {
	e = e || window.event;
	mouse.dragapproved = false;
	if (mouse.srcElement) {
		mouse.srcElement.style.left = mouse.srcLeftPos + e.clientX
				- mouse.eventX;
		mouse.srcElement.style.top = mouse.srcRightPos + e.clientY
				- mouse.eventY;
		document.onmousemove = null;
	}
};
/*-----------------------------------------file文件操作------------------------------------------------*/
var file = {
	// 是否显示上传进度
	showStatus : false,
	// 等待
	wit : null,
	// 客 户端文件名
	clientFileName : null,
	// 上传框架id
	uploadFrameId : null,
	// -1:单个文件上传 (单文件上传不提交)
	// 1:多个文件 （上传完毕后上传下一个文件) 0：多文件上传完毕 （提交表单)
	multiFile : -1,
	// 上传回调函数
	uploadCallBack : function(fileInfo, clientFileName, editor) {
		alert(fileInfo.FileName);
		alert(clientFileName);
	},
	// 如果图片很小，不会通过getStatus方法，则在回调时主动清除上传状态
	clearStatus : function() {
		if (this.showStatus) {
			document.body.removeChild($('divStatus'));
		}
		window.clearInterval(this.wit);
	},
	// 文件序列号
	fileSerialNumber : null,
	// 文件上专前的验证方法由 input file 的onchange响应
	validateUploadFile : function() {
	},
	// 文件上传成功后的重置方法
	// 因为文件上传完毕之后需要重置上传序列号。所以一定要手动设置该方法
	reset : function() {
		var tempSrc = $(this.uploadFrameId).src;
		$(this.uploadFrameId).src = "about:blank";
		$(this.uploadFrameId).src = tempSrc;
	},
	// 获取上传的input type="file"控件
	getUploadFile : function() {
		var frame;
		if (this.uploadFrameId) {
			frame = $(this.uploadFrameId);
		} else {
			frame = $("fileUpload");
		}
		return frame.contentWindow.document.getElementById("file_upload");
	},
	// 获取文件序列号
	getFileSerialNumber : function() {
		return this.fileSerialNumber;
	},
	setFileSerialNumber : function(serialNumber) {
		this.fileSerialNumber = serialNumber;
	},
	// 获取文件的全路径文件名?
	getFullPath : function(obj) {
		if (obj) {
			if (browser.appName() == "IE") {
				obj.select();
				var txt = document.frames[0].document.selection.createRange().text;
				document.frames[0].document.selection.empty();
				return txt;
			} else if (browser.appName() == "Firefox") {

				if (obj.files) {
					return obj.files.item(0).getAsDataURL();
				}
				return obj.value;
			}
			return obj.value;
		}
	},
	// 获文件扩展名
	getExtension : function(fileName) {
		var lastIndex = fileName.indexOf("?");
		if (lastIndex == -1) {
			lastIndex = fileName.length;
		}
		return fileName.substring(fileName.lastIndexOf("."), lastIndex)
				.toLocaleLowerCase();
	},
	// 获取文件名
	getFileName : function(fileName) {
		if (fileName.indexOf("\\") != -1) {
			return fileName.substring(fileName.lastIndexOf("\\") + 1);
		} else {
			return fileName;
		}
	},
	// 验证文件类型
	checkFileType : function(fileName, righty_type, errorCtrl) {
		var fileExtension = this.getExtension(fileName);
		var result = false;
		for ( var i = 0; i < righty_type.length; i += 1) {
			if (righty_type[i].toLocaleLowerCase() == fileExtension
					|| '.' + righty_type[i].toLocaleLowerCase() == fileExtension) {
				result = true;
			}
		}
		if (result) {
			$(errorCtrl).className = "prompt";
			$(errorCtrl).innerHTML = "";
		} else {
			$(errorCtrl).className = "error";
			$(errorCtrl).innerHTML = "!只支持:" + righty_type + "格式";
			jalert("文件格式不正确，只支持以下格式:\n" + righty_type, "sad");
		}
		return result;
	},
	// 如果editor为null则表示非编辑器控件
	uploadClick : function(showState, oldFileUrl, uploadingFrameId, editor,
			srcElement) {
		this.showStatus = showState;
		// 如果显示状态并且状态控件已经显示则说明已经有文件正在上传中...
		if (showState != false && $("divStatus")) {
			jalert(this.clientFileName + "正在上传中,请稍侯...", "sad");
			return false;
		}
		// 设置正在上传的文件控件ID
		this.uploadFrameId = uploadingFrameId;
		// 如果没有选择上传文件
		if (this.getUploadFile(uploadingFrameId).value == "") {
			var fileInfo = "{FileName:'"
					+ (oldFileUrl && oldFileUrl != 'undefined' ? oldFileUrl
							: "") + "'}";
			// 上传事件回调函数 具体处理方式在uploadCallBack中进行操作
			file.uploadCallBack(fileInfo.toJson(), "");
			// 自动批量上传不是用事件触发的,所以srcElement可能为null
			if (srcElement)
				m.show("请选择上传文件!", srcElement);
			return false;
		} else {
			// 客户端文件名
			this.clientFileName = this.getUploadFile().value;
			// 设置上传框架
			var uploadFrame = uploadingFrameId ? $(uploadingFrameId)
					: $("fileUpload");
			// 设置当前文件的序列号
			this.setFileSerialNumber(uploadFrame.contentWindow.document
					.getElementById("fileInfo").value.split('|')[1]);
			// 如果要显示状态
			if (showState != false) {
				// 如果状态控件不存在则创建
				if (!$("divStatus")) {
					var divStatus = $c("div");
					divStatus.id = "divStatus";
					divStatus.style.cssText = "width:260px;height:100px;position:absolute;color:#ffffff;background:#000000;font-size:10pt;border:#ccc 1px solid;text-align:left;";
					divStatus.innerHTML = "服务器正在加载文件信息...";
					document.body.appendChild(divStatus);
					divStatus.style.top = position
							.getAbsoluteTopPosByCtrl(uploadFrame) - 10;
					divStatus.style.left = position
							.getAbsoluteLeftPosByCtrl(uploadFrame);
					setOpacity(divStatus, 90);
				}
			}
			// 提交
			uploadFrame.contentWindow.document.forms[0].submit();
			// 设置状态跟踪
			if (typeof (editor) == "undefined") {
				// 非编辑器控件
				this.wit = window.setInterval("file.getStatus(" + showState
						+ ")", 1000);
			} else {
				this.wit = window.setInterval("file.getStatus(" + showState
						+ "," + editor.obj + ")", 1000);
			}
		}
	},
	getStatus : function(showState, editor) {
		// 根据当前文件的序列号,实时获取当前文件的上传状态
		ajax
				.req(
						"GET",
						rootPath + "/FileUpload?fileSerialNumber="
								+ this.getFileSerialNumber() + "&t="
								+ Math.random(),
						function(xmlHttpRequest) {
							if (xmlHttpRequest.responseText) {
								var statusJson = xmlHttpRequest.responseText
										.toJson();
								var statusString = new Array();
								var iserror = true;
								var finish = false;
								// 未加载完即获取则继续loading
								if (xmlHttpRequest.responseText
										.indexOf("loading") == 0) {
									statusString.push("服务器正在加载文件信息...");
								}
								// 上传格式错误
								else if (statusJson.FileType
										.indexOf("errorType") == 0) {
									statusString
											.push(
													"只支持"
															+ statusJson.FileType
																	.substring(statusJson.FileType
																			.indexOf('|'))
															+ "格式的文件", "sad");
									finish = true;
								}
								// 文件超过上传大小状态
								else if (statusJson.ReadedFileLength == -1) {
									statusString
											.push("文件:<span class='highlight'>《"
													+ file
															.getFileName(file.clientFileName)
													+ "》</span><br/>");
									statusString.push("大小:"
											+ statusJson.ContentLengthStr
											+ "<br/>");
									statusString.push("已超过允许上传大小！请选择其他文件。");
									finish = true;
								}
								// 文件上传超时
								else if (statusJson.ReadedFileLength == -2) {
									statusString
											.push("文件:<span class='highlight'>《"
													+ file
															.getFileName(file.clientFileName)
													+ "》</span><br/>");
									statusString.push("大小:"
											+ statusJson.ContentLengthStr
											+ "<br/>");
									statusString.push("网络链接超时.请稍侯....");
									finish = true;
								}
								// 正常显示状态
								else {
									var status = Math
											.ceil(parseFloat(statusJson.ReadedFileLength)
													/ parseFloat(statusJson.ContentLength)
													* 1000000)
											/ 10000 + "%";
									statusString
											.push("正在上传文件<br/><span class='highlight'>《"
													+ file
															.getFileName(file.clientFileName)
													+ "》</span><br/>");
									statusString.push("文件大小:"
											+ statusJson.ContentLengthStr
											+ "<br/>");
									statusString.push("上传大小:"
											+ statusJson.ReadedFileLengthStr
											+ "<br/>");
									statusString.push("上传进度:" + status);
									// 上传完毕
									if (statusJson.ContentLength <= statusJson.ReadedFileLength) {
										if (file.uploadCallBack) {
											// 回调上传完毕后要执行的函数
											file
													.uploadCallBack(
															statusJson,
															file.clientFileName,
															editor);
										}
										finish = true;
									} else {
										finish = false;
									}
									iserror = false;
								}
								// 如果文件很小可能未执行到此处即回调
								// 然后该方法会继续执行,所以会做此判断
								if (file.wit) {
									if (showState) {
										$("divStatus").innerHTML = statusString
												.join("");
									}
								}
								if (finish) {
									if (showState) {
										window
												.setTimeout(
														"document.body.removeChild($('divStatus'));",
														1000);
									}
									window.clearInterval(file.wit);
									if (iserror) {
										jalert(statusString.join(""), "sad");
									}
									return false;
								}
							}
						}, "true");
	}
};

/*------------------------------------validate 表单验证------------------------------------------------*/
/*
 * ctrlId errorCtrlId prompt nullError emailError lengthError dateError
 */
var v = {
	emptyString : '',
	rightmessage : '<img src="' + resource + '/system/images/succeed.gif"/>',
	click : function(validateInfo) {
		if ($(validateInfo.ctrlId).value.trim() == validateInfo.prompt) {
			$(validateInfo.ctrlId).style.color = "#000";
			$(validateInfo.ctrlId).value = "";
		}
	},
	blur : function(validateInfo) {
		if ($(validateInfo.ctrlId).value.trim() == ""
				|| $(validateInfo.ctrlId).value.trim() == validateInfo.prompt) {
			$(validateInfo.ctrlId).style.color = "#ccc";
			$(validateInfo.ctrlId).value = validateInfo.prompt;
		}
	},
	// 设置当前控件的父控件背景
	setbackground : function(parentLevel, color) {
		if (typeof (parentLevel) == undefined)
			parentLevel = 2;
		if (parentLevel > 0) {
			var background = $(errorId);
			for ( var i = 0; i < parentLevel; i++) {
				background = background.parentNode;
			}
			background.style.background = color;
		}
	},
	showMessage : function(validateInfo) {
		var errorId = validateInfo.errorCtrlId;
		var message = validateInfo.prompt;
		$(errorId).className = "prompt";
		$(errorId).innerHTML = message;
		this.setbackground(validateInfo.parentLevle, "#ff9900");
	},
	clearMessage : function(validateInfo) {
		var errorId = validateInfo.errorCtrlId;
		$(errorId).innerHTML = this.rightmessage;
		this.setbackground(validateInfo.parentLevle, "#ffffff");
		var ctrlId = $(validateInfo.ctrlId);
		if (ctrlId.value == "" && validateInfo.defaultValue) {
			ctrlId.value = validateInfo.defaultValue;
		}
	},
	/* 获取验证信息 */
	getValidateResult : function(errorArray) {
		var wrongInfo = "";
		for ( var i = 0; i < errorArray.length; i += 1) {
			if (!errorArray[i].isExist) {
				if (v.isNull(errorArray[i]) && errorArray[i].nameRole == true) {
					v.nameRole(errorArray[i]);
				}
			}
		}
		for ( var i = 0; i < errorArray.length; i += 1) {
			if ($(errorArray[i].errorCtrlId).className == "error") {
				wrongInfo += ((browser.appName() == "IE") ? $(errorArray[i].errorCtrlId).innerText
						: $(errorArray[i].errorCtrlId).textContent)
						+ "\n";
			}
		}
		if (wrongInfo.trim() != "") {
			alert(wrongInfo);
			return false;
		} else {
			return true;
		}
	},
	setError : function(validateInfo) {

		$(validateInfo.errorCtrlId).innerHTML = "!" + validateInfo.setError;
		$(validateInfo.errorCtrlId).className = "error";
		$(validateInfo.ctrlId).style.backgroundColor = "#FFFBE7";
	},
	clearError : function(validateInfo) {
		$(validateInfo.errorCtrlId).innerHTML = v.rightmessage;
		$(validateInfo.errorCtrlId).className = "prompt";
		$(validateInfo.errorCtrlId).style.backgroundColor = "#ffffff";

	},
	// 所有出错信息
	summary : function(vobj, error1, error2, error3, error4) {
		var errorArray = new Array(error1, error2, error3, error4);
		for ( var i = 0; i < errorArray.length; i += 1) {
			if (errorArray[i]
					&& document.getElementById(errorArray[i]).className == "error") {
				vobj.style.backgroundColor = "#FFFBE7";
				return true;
			}
		}
		return false;
	},
	_baseValidate : function(validateInfo) {
		this.setbackground(validateInfo.parentLevle, "#ffffff");
		var vobj = $(validateInfo.ctrlId);
		var objvalueLength = (vobj.tagName.toUpperCase() == "SELECT" && vobj.multiple == true) ? vobj.options.length
				: vobj.value.getByteLength();
		var objvalue = vobj.value;
		var vExpress = null;
		var errorInfo = null;
		var vmax = true;
		var vmin = true;
		if (objvalueLength == 0) {
			if (validateInfo.defaultValue != undefined) {
				vobj.value = validateInfo.defaultValue;
				vExpress = true;
			} else {
				if (validateInfo.allowNull) {
					vExpress = true;
				} else {
					vExpress = false;
					errorInfo = validateInfo.nullError;
				}
			}
		} else {
			// 最长限制默认为true
			if (validateInfo.maxLength
					&& objvalueLength > validateInfo.maxLength) {
				vmax = false;
				errorInfo = validateInfo.lengthError;
			}
			// 最小长度限制默认为true

			if (validateInfo.minLength
					&& objvalueLength < validateInfo.minLength) {
				vmin = false;
				errorInfo = validateInfo.lengthError;
			}

			if (vmax && vmin) {
				switch (validateInfo.validateOption) {
				case "nameRole":
					vExpress = objvalue.search(/^[a-zA-Z0-9_]{6,20}$/) != -1;
					errorInfo = validateInfo.nameRoleError;
					break;
				case "isEmail":
					vExpress = objvalue
							.search(/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/) != -1;
					errorInfo = validateInfo.emailError;
					break;
				case "isNull":
					var oldErrorInfo = $(validateInfo.errorCtrlId).innerHTML
							.trim().substring(1);
					if ($(validateInfo.errorCtrlId).className == "error"
							&& oldErrorInfo != validateInfo.nullError
							&& oldErrorInfo != validateInfo.lengthError) {
						vExpress = false;
						errorInfo = oldErrorInfo;
					} else if (validateInfo.otherCtrlId
							&& $(validateInfo.otherCtrlId).value.trim().length == 0) {
						vExpress = false;
						errorInfo = validateInfo.nullError;
					} else {
						vExpress = true;
					}
					break;
				case "isEquel":
					vExpress = (vobj.value.trim() == $(validateInfo.otherCtrlId).value);
					errorInfo = validateInfo.noEqualError;
					break;
				case "isTel":
					vExpress = objvalue
							.search(/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/) != -1;
					errorInfo = validateInfo.telError;
					break;
				case "isMobile":
					vExpress = vobjvalue.search(/^1[\d]{10}$/) != -1;
					errorInfo = validateInfo.mobileError;
					break;
				case "isIdCard":
					vExpress = objvalue
							.search(/^([1-9]([0-9]{16}|[0-9]{13})([0-9]|x|X))$/) != -1;
					errorInfo = validateInfo.idCardError;
					break;
				case "isWord":
					vExpress = objvalue.search(/^[\x00-\x80]$/) != -1;
					errorInfo = validateInfo.wordError;
					break;
				case "isDigital":
					vExpress = objvalue.search(/^\d*$/) != -1;
					if (vExpress) {
						var value = parseInt(objvalue);
						if ((validateInfo.minValue || validateInfo.minValue == 0)
								&& value < validateInfo.minValue) {
							vExpress = false;
							errorInfo = validateInfo.lessMin;
						} else if ((validateInfo.maxValue || validateInfo.maxValue == 0)
								&& value > validateInfo.maxValue) {
							vExpress = false;
							errorInfo = validateInfo.greatMax;
						}
					} else {
						errorInfo = validateInfo.digitalError;
					}
					break;

				}
			}
		}
		// 最终验证
		if (vExpress && vmax && vmin) {
			vobj.style.backgroundColor = "#ffffff";
			$(validateInfo.errorCtrlId).className = "prompt";
			$(validateInfo.errorCtrlId).innerHTML = v.rightmessage;
			return true;
		} else {
			$(validateInfo.errorCtrlId).className = "error";
			$(validateInfo.errorCtrlId).innerHTML = "!" + errorInfo;
			vobj.style.backgroundColor = "#FFFBE7";
			return false;
		}

	},
	nameRole : function(validate) {
		validate.validateOption = "nameRole";
		return this._baseValidate(validate);
	},
	isEmail : function(validateInfo) {
		validateInfo.validateOption = "isEmail";
		return this._baseValidate(validateInfo);
	},
	isTel : function(validateInfo) {
		validateInfo.validateOption = "isTel";
		return this._baseValidate(validateInfo);
	},
	isMobile : function(validateInfo) {
		validateInfo.validateOption = "isMobile";
		validateInfo.minLength = validateInfo.maxLength = 13;
		return this._baseValidate(validateInfo);
	},
	isIdCard : function(validateInfo) {
		validateInfo.validateOption = "isIdCard";
		return this._baseValidate(validateInfo);
	},
	isNull : function(validateInfo) {
		validateInfo.validateOption = "isNull";
		return this._baseValidate(validateInfo);
	},
	isWord : function(validateInfo) {
		validateInfo.validateOption = "isWord";
		return this._baseValidate(validateInfo);
	},
	isEquel : function(validateInfo) {
		validateInfo.validateOption = "isEquel";
		return this._baseValidate(validateInfo);
	},
	allowInputOption : function(validateInfo) {

		if (!validateInfo.defaultValue) {
			validateInfo.defaultValue = validateInfo.options[0];
		}

		for ( var i = 0; i < validateInfo.options.length; i += 1) {

			if ($(validateInfo.ctrlId).value == validateInfo.options[i]) {
				break;
			}
		}
		if (i == validateInfo.options.length) {
			$(validateInfo.ctrlId).value = validateInfo.defaultValue;
		}
		this.clearMessage(validateInfo);
	},
	isDigital : function(validateInfo) {
		validateInfo.validateOption = "isDigital";
		return this._baseValidate(validateInfo);
	},
	isImgSize : function(vobj, defaultValue) {
		var size = vobj.value.split('*');
		if (size.length == 2) {
			if (size[0].search(/^[0-9]+.?[0-9]$/) == -1
					|| size[1].search(/^[0-9]+.?[0-9]$/) == -1) {
				vobj.value = defaultValue;
			}
		} else {
			vobj.value = defaultValue;
		}
	},
	isFileLength : function(vobj, defaultValue) {
		if (vobj.value.toUpperCase().indexOf("M") != -1) {
			if (vobj.value.toUpperCase().split('M')[0]
					.search(/^[0-9]+.?[0-9]$/) != -1) {
				vobj.value = vobj.value.toUpperCase().split('M')[0] + "MB";
			} else {
				vobj.value = defaultValue;
			}
		} else if (vobj.value.toUpperCase().indexOf("K") != -1) {
			if (vobj.value.toUpperCase().split('K')[0]
					.search(/^[0-9]+.?[0-9]$/) != -1) {
				vobj.value = vobj.value.toUpperCase().split('K')[0] + "KB";
			}
			vobj.value = defaultValue;
		} else {
			vobj.value = defaultValue;
		}

	},
	updateTxtCount : function(obj, showCtrl, maxLength, e) {
		e = e || window.event;
		if (e.keyCode < 37 || e.keyCode > 40) {
			var length = obj.value.getByteLength();
			var allowInputLength = maxLength - length;
			if (allowInputLength <= 0) {
				$(showCtrl).innerHTML = 0;
				obj.value = obj.value.subString(maxLength, false);
			} else {
				$(showCtrl).innerHTML = allowInputLength;
			}
		}
	}
};
/*-------------------------------------前台JS控件相关 webtal gridview---------------------------------------------*/
var webtab = {
	config : {
		useIndex : false
	},
	currentMenuNo : 0,
	setTab : function(tabNo, _currentMenuNo) {
		var tab = document.getElementById("tab" + tabNo);
		var tabchilds = $Son(tab, "DIV");
		var title = tabchilds[0];
		var content = tabchilds[1];

		var tabList = $Son(title, "li");
		var hyperMore = $Son(tabList[tabList.length - 1], "a");
		var contentList = $Son(content, "div");
		for ( var i = 0; i < tabList.length; i += 1) {
			if (this.config.userIndex) {
				tabList[0].className = "index";
			}

			if (i == _currentMenuNo) {
				tabList[i].className = "select";
				contentList[i].className = "block";
				this.currentMenuNo = _currentMenuNo;
				if (hyperMore[i])
					hyperMore[i].className = "block";
			} else if (tabList[i].className != "close"
					&& tabList[i].className != "more") {
				tabList[i].className = "noselect";
				contentList[i].className = "none";
				if (hyperMore[i])
					hyperMore[i].className = "none";
			}
		}
		this.selectedCallBack(tabNo, _currentMenuNo);
	},
	selectedCallBack : function(tabNo, _currentMenuNo) {
		return;
	}
};
/*--------------------------select 控件相关---------------------------------------------*/
var sl = {
	add : function(text, value, descSelect) {
		var newoption = new Option(text, value);
		if (!this.isInDescSelect(newoption, descSelect))
			descSelect.options.add(newoption);
	},
	isInDescSelect : function(srcOption, descSelect) {
		var flag = false;
		for ( var j = 0; j < descSelect.options.length; j += 1) {
			if (srcOption.value == descSelect.options[j].value)
				flag = true;
		}
		return flag;
	},

	addToDescSelect : function(srcSelect, descSelect) {
		var hasSelected = false;
		for ( var i = 0; i < srcSelect.options.length; i += 1) {

			if (srcSelect.options[i].selected == true) {
				var value = srcSelect.options[i].value;
				var text = srcSelect.options[i].innerHTML;
				var newoption = new Option(text, value);
				if (!IsInDescSelect(srcSelect.options[i], descSelect))
					descSelect.options.add(newoption);
				hasSelected = true;
			}
		}
		if (hasSelected == false) {
			if (!this.isInDescSelect(srcSelect.options[0], descSelect)) {
				var value = srcSelect.options[0].value;
				var text = srcSelect.options[0].innerHTML;
				var newoption = new Option(text, value);
				descSelect.options.add(newoption);
			}
		}
	},

	addAllDescSelect : function(srcSelect, descSelect) {
		for ( var i = 0; i < srcSelect.options.length; i += 1) {
			var text = srcSelect.options[i].innerHTML;
			var value = srcSelect.options[i].value;
			var newoption = new Option(text, value);
			if (!IsInDescSelect(srcSelect.options[i], descSelect))
				descSelect.options.add(newoption);
		}
	},
	sub : function(srcSelect, isSubFirst) {
		if (typeof (srcSelect) == "string") {
			srcSelect = $(srcSelect);
		}
		var hasSelected = false;
		for ( var i = srcSelect.options.length - 1; i >= 0; i -= 1) {
			if (srcSelect.options[i].selected == true) {
				srcSelect.options.remove(i);
				hasSelected = true;
			}
		}
		if (isSubFirst != false) {
			if (hasSelected == false) {
				srcSelect.options.remove(0);
			}
		}
	},
	subAll : function(srcSelect) {
		for ( var i = srcSelect.options.length - 1; i >= 0; i -= 1) {
			srcSelect.options.remove(i);
		}
	},
	moveUpDown : function(direction, srcSelect) {
		if (srcSelect.selectedIndex < 0)
			return;

		if (direction < 0) {
			if (srcSelect.selectedIndex == 0)
				return;
		} else {
			if (srcSelect.selectedIndex == srcSelect.options.length - 1)
				return;
		}

		var srcOption = srcSelect.options[srcSelect.selectedIndex];
		var toOption = srcSelect.options[srcSelect.selectedIndex + direction];

		var text = srcOption.text;
		var value = srcOption.value;

		srcOption.text = toOption.text;
		srcOption.value = toOption.value;

		toOption.text = text;
		toOption.value = value;

		srcSelect.selectedIndex += direction;
	},
	selectAll : function(selectList) {
		if (typeof (selectList) == "string") {
			selectList = $(selectList);
		}
		for ( var i = 0; i < selectList.options.length; i++) {
			selectList.options[i].selected = true;
		}
	}
};

/*---------------------------------------------JGridView全选和单选---------------------------------------------*/
var gridView = {
	keyType : "uuid",// int
	id : "grvManageList",
	resultCtrlId : "",
	getTable : function() {
		return $(this.id);
	},
	getCellIndex : function(checkBox) {
		return checkBox.parentNode.cellIndex;
	},
	allCheckClick : function(allCheckBox) {
		var checkBoxList = $name(this.id);
		for ( var i = 0; i < checkBoxList.length; i += 1) {
			var checkBox = checkBoxList[i];
			checkBox.checked = allCheckBox.checked;
		}
	},
	recordCheckClick : function(checkBox, allCheckBox) {
		if (checkBox.checked == false) {
			$(allCheckBox).checked = false;
		} else {
			var isAllCheck = true;
			var checkBoxList = $name(this.id);
			for ( var i = 1; i < checkBoxList.length; i += 1) {
				var checkBox = checkBoxList[i];
				if (checkBox.checked == false)
					isAllCheck = false;
			}
			if (isAllCheck == true) {
				$(allCheckBox).checked = true;
			}
		}
	},
	mustSelect : function(message) {
		var selectedId = new Array();
		// var gridViewRowCount=this.getTable().rows.length;
		var checkBoxList = $name(this.id);
		var selectId = null;
		for ( var i = 0; i < checkBoxList.length; i += 1) {
			var checkBox = checkBoxList[i];
			if (checkBox.tagName.toLowerCase() == "input"
					&& checkBox.checked == true) {
				selectId = checkBox.id;
				if (this.keyType == "uuid") {
					selectedId.push("'" + selectId + "'");
				} else {
					selectedId.push(selectId);
				}
			}
		}
		if (selectedId.length == 0) {
			if (system.noSelectRecord) {
				alert(system.noSelectRecord);
			} else {
				alert("plase defined system.noSelectRecord");
			}
			return false;
		} else {
			if (selectedId.length == 1) {
				selectedId.pop();
				selectedId.push(selectId);
			}
			if (!message) {
				return selectedId;
			} else {
				if (window.confirm(message)) {
					return selectedId;
				} else {
					return false;
				}
			}
		}
	},
	onlyCheckedOne : function(message) {
		var strMessage = null;
		if (message) {
			strMessage = message;
		} else {
			if (system.onlySelectOneRecord) {
				strMessage = system.onlySelectOneRecord;
			} else {
				alert("please defined system.onlySelectOneRecord");
			}
		}
		// var rowsCount=this.getTable().rows.length;
		var checkCount = 0;
		// var selectedId=null;
		var checkBoxList = $name(this.id);
		for ( var i = 1; i < checkBoxList.length; i += 1) {
			var checkBox = checkBoxList[i];
			if (checkBox.checked == true) {
				checkCount += 1;
				selectedId = checkBox.id;
			}
		}

		if (checkCount == 0) {
			if (system.noSelectRecord) {
				alert(system.noSelectRecord);
			} else {
				alert("please defined system.noSelectRecord!");
			}
			return false;
		} else if (checkCount != 1) {
			alert(strMessage);
			return false;
		} else {
			return true;
		}
	},
	action : function(postUrl, message, isOnlyOne) {

		var result = isOnlyOne ? this.onlyCheckedOne(message) : this
				.mustSelect(message);
		if (result) {
			$(this.resultCtrlId).value = result;
			if (postUrl == "return") {
				return true;
			} else {
				doaction(postUrl);
			}
		}
	}
};
var page = {
	toTargetPage : function(pageCount, pageFormat, srcElement) {
		if (parseInt($('defPageIndex').value) <= 0
				|| parseInt($('defPageIndex').value) > pageCount) {
			m.show('超出页码范围', srcElement);
		} else if ($('defPageIndex').value.trim() == $('spanCurrentPageIndex').innerText
				.trim()) {
			m.show('当前页即是目标页', srcElement);
		} else {
			window.location.href = pageFormat.replace("$pageIndex",
					$('defPageIndex').value);
		}
	},
	defaction : null,
	action : function(pageIndex, actionKey) {
		$("currentPageIndex").value = pageIndex;
		window.location.href = "#top";
		if (this.defaction != null) {
			this.defaction(pageIndex);
		} else {
			doaction(null, actionKey);
		}
	}
};
var table = {
	id : "tagList",
	tr : new Array(),
	obj : function() {
		var t = document.getElementById(this.id);
		if (t == null) {
			return null;
		} else {
			var tbody = t.getElementsByTagName("tbody")[0];
			if (tbody == null) {
				alert("请在表格定义tbody节");
			} else {
				return tbody;
			}
		}

	},
	_initCell : function(cell, i, j) {
		cell.style.cssText = this.tr[i].td[j].cssText;
		cell.className = this.tr[i].td[j].className;
		cell.align = this.tr[i].td[j].align;
		cell.innerHTML = this.tr[i].td[j].innerHTML;
		if (this.tr[i].td[j].colspan)
			cell.setAttribute("colspan", this.tr[i].td[j].colspan);
	},
	_initRow : function(row, i) {
		row.style.cssText = table.tr[i].cssText;
		if (table.tr[i].className && table.tr[i].className != "")
			row.className = table.tr[i].className;
		for ( var j = 0; j < this.tr[i].td.length; j++) {
			var cell = row.insertCell(-1);
			this._initCell(cell, i, j);
		}
	},
	init : function() {
		var tab = document.createElement("table");
		tab.id = this.id;
		for ( var i = 0; i < this.tr.length; i++) {
			tab.appendChild(this._initRow(i));
		}
		document.getElementById(this.initCtrlId).appendChild(tab);
	},
	appendRow : function() {
		for ( var i = 0; i < this.tr.length; i++) {
			var row = this.obj().insertRow(-1);
			this._initRow(row, i);
		}
	},
	insertRow : function(rowIndex) {
		for ( var i = 0; i < this.tr.length; i++) {
			var row = this.obj().insertRow(rowIndex);
			this._initRow(row, i);
		}
	},
	updateRow : function(rowIndex) {
		for ( var i = 0; i < this.tr[0].td.length; i++) {
			if (this.tr[0].td[i].innerHTML) {
				this.obj().rows[rowIndex].cells[i].innerHTML = this.tr[0].td[i].innerHTML;
			}
		}
	},
	removeRow : function(rowIndex) {
		this.obj().deleteRow(rowIndex);
	}
};

/*
 * 日期2009 08 09 作者:张立志 邮箱:zhang-lizhi@hotmail.com QQ: 492006183 IE6 ie7 遨游
 * 火狐下测试通过 功能说明:系统提示对话框 参数： msg：提示信息 isone:是否为根目录 type:提示类型 title:标题
 * themes:全局变量设置前台皮肤图片 returnCallBack:关闭后事件 例子: win.isInFrame=false;
 * jalert("请不要关闭本页,数据保存中,请稍侯!<br/>保存完毕后页面将自动关闭!","wait","友情提示");
 * jalert("系统已被锁定","lock","温馨提示",srcElement);
 * jalert("对不起！操作有误!","sad","温馨提示",srcElement);
 * jalert("恭喜!操作成功!","smile","温馨提示",srcElement);
 * jalert("您确认继续操作吗!","ask","温馨提示",srcElement);
 * jalert("defualtValue!","input","温馨提示",srcElement);
 */
var win = {
	config : {
		isInFrame : false,
		showHead : true,
		titleHeight : 45,
		currentWindow : window,
		bgsound : resource + "/system/media/sound.wav",
		titleImg : resource + "/system/themes_default/panel.gif",
		closeBtnImg : resource + "/themes_default/panel.gif",
		OKBtnImg : resource + "/system/themes_default/panel.gif",
		smileImg : resource + "/system/themes_default/smile.gif",
		sadImg : resource + "/system/themes_default/sad.gif",
		lockImg : resource + "/system/themes_default/btn.png",
		waitImg : resource + "/system/themes_default/btn.png",
		askImg : resource + "/system/themes_default/smile.gif",
		jalert : {
			height : "160px",
			width : "250px",
			closeCallBack : function() {
			},
			v : {
				ctrlId : "txtJalertInput",
				errorCtrlId : "errorJalert",
				prompt : "\u8bf7\u8f93\u5165:"
			}
		},
		box : {
			// 用来保存box对话框中的选择项
			descContainer : null
		}
	},
	getWindow : function() {
		return (this.config.isInFrame ? window.parent : window);
	},
	getScrollTop : function() {
		return this.getWindow().pageYOffset
				|| this.getWindow().document.documentElement.scrollTop
				|| this.getWindow().document.body.scrollTop;
	},
	getBackGroundDivHeight : function() {
		var scroolTop = this.config.isInFrame ? 0 : win.getScrollTop();
		return (document.body.clientHeight + scroolTop) + "px";
	},
	addSound : function() {
		// 背景音乐
		var sound = this.getWindow().document.createElement("bgsound");
		sound.id = "sound";
		sound.src = this.config.bgsound;
		this.getWindow().document.body.appendChild(sound);
	},
	hiddenOrShowTag : function(tagName, isShow, parentElement) {
		var tags = parentElement ? parentElement.getElementsByTagName(tagName)
				: $tag(tagName);
		for ( var i = 0; i < tags.length; i++) {
			tags[i].zIndex = -1;
			if (!isShow) {
				tags[i].style.visibility = "hidden";
			} else {
				tags[i].style.visibility = "visible";
			}
		}
	},
	hiddenTags : function() {
		this.hiddenOrShowTag("select");
		this.hiddenOrShowTag("object");
	},
	showTags : function() {
		this.hiddenOrShowTag("select", true);
		this.hiddenOrShowTag("object", true);
	},
	addBackDiv : function() {
		var backDiv = this.getWindow().document.createElement("div");
		var documentHeight = Math.max(
				this.getWindow().document.body.scrollHeight,
				this.getWindow().document.documentElement.scrollHeight);
		backDiv.id = "backDiv";
		backDiv.zIndex = 1000;
		setOpacity(backDiv, 80);
		backDiv.style.position = "absolute";
		backDiv.style.width = this.getWindow().document.body.offsetWidth + "px";
		backDiv.style.height = documentHeight + "px";
		backDiv.style.left = "0px";
		backDiv.style.top = "0px";
		backDiv.style.backgroundColor = "#000000";
		this.getWindow().document.body.appendChild(backDiv);
	},
	addMsgDiloag : function() {
		var diloag = this.getWindow().document.createElement("div");
		diloag.zIndex = 1000;
		diloag.id = "diloag";
		diloag.style.cssText = "position:absolute;border:#ccc 3px solid;text-align:center;font-size:10pt;background:white;";
		diloag.style.width = this.config.jalert.width;
		diloag.style.height = this.config.jalert.height;
		this.getWindow().document.body.appendChild(diloag);
	},
	addPanel : function(width, height, title, url) {
		var panel = this.getWindow().document.createElement("div");
		panel.zIndex = 1000;
		panel.id = "diloag";
		panel.style.cssText = "position:absolute;text-align:center;font-size: 10pt;background:white;";
		panel.style.width = width + "px";
		panel.style.height = height + "px";
		this.getWindow().document.body.appendChild(panel);
		this.addTitle(title);
		this.addRightClose();
		if (url) {
			var frame = this.getWindow().document.createElement("iframe");
			frame.setAttribute("frameborder", "0", 0);
			frame.scrolling = "no";
			frame.id = "panel";
			frame.src = url;
			frame.style.width = (width - 4) + "px";
			frame.style.height = (height
					- (this.config.showHead ? this.config.titleHeight : 0) - 5)
					+ "px";
			panel.appendChild(frame);
		} else {
			var content = this.getWindow().document.createElement("div");
			content.id = "panelcontent";
			content.style.cssText = "text-align:left;font-size:10pt;margin:5px;";
			content.style.width = (width - 10) + "px";
			content.style.height = (height
					- (this.config.showHead ? this.config.titleHeight : 0) - 50)
					+ "px";
			content.style.overflow = "scroll";
			panel.appendChild(content);
			var btnOk = $c("input");
			btnOk.type = "button";
			btnOk.style.cssText = "width:80px;height:30px;";
			btnOk.value = "确定";
			btnOk.onclick = function() {
				if (win.ok) {
					win.ok();
				} else {
					alert("ok");
				}
			};
			panel.appendChild(btnOk);
			var btnCancel = $c("input");
			btnCancel.type = "button";
			btnCancel.style.cssText = "width:80px;height:30px;";
			btnCancel.value = "关闭";
			btnCancel.onclick = function() {
				win.closeClick();
			};
			panel.appendChild(btnCancel);
		}
	},
	addTitle : function(title) {
		if (this.config.showHead) {
			var divtitle = this.getWindow().document.createElement("div");
			divtitle.id = "divtitle";
			divtitle.style.cssText = "cursor:move;width:100%;height:"
					+ this.config.titleHeight + "px;background-repeat:repeat;";
			divtitle.innerHTML = "";
			divtitle.style.backgroundImage = "url(" + this.config.titleImg
					+ ")";
			this.getWindow().document.getElementById("diloag").appendChild(
					divtitle);
			// 真正的标题文本
			var divleft = this.getWindow().document.createElement("div");
			// divleft.unselectable = "on";
			divleft.className = "drag-pp";
			divleft.id = "divleft";
			divleft.style.cssText = "float:left;width:85%;height:{0}px;line-height:{0}px;color:white;text-align:left;padding:2px;font-size:10pt;font-weight: bold;"
					.format(this.config.titleHeight);
			divleft.innerHTML = title ? title : websitName + "提醒您:";
			this.getWindow().document.getElementById("divtitle").appendChild(
					divleft);
		}
	},
	addRightClose : function() {
		// 关闭按钮
		if (this.config.showHead) {
			var divright = this.getWindow().document.createElement("div");
			divright.id = "divright";
			divright.style.cssText = "float:right;width:20px;line-height:"
					+ this.config.titleHeight
					+ "px;color:white;text-align:right;font-size:13pt;cursor:pointer;";
			divright.innerHTML = "\xd7";
			divright.onclick = function() {
				win.closeClick();
			};
			this.getWindow().document.getElementById("divtitle").appendChild(
					divright);
		}
	},
	addOK : function() {
		var btnOK = this.getWindow().document.createElement("input");
		btnOK.id = "btnOK";
		btnOK.type = "button";
		btnOK.style.cssText = "cursor:pointer;width:80px;height:30px;color:black;";
		btnOK.style.backgroundImage = "url(" + this.config.OKBtnImg + ")";
		btnOK.value = "\u786e\u5b9a";
		btnOK.onclick = function() {
			win.okClick();
		};
		this.getWindow().document.getElementById("diloag").appendChild(btnOK);
	},
	addClose : function() {
		var btnclose = this.getWindow().document.createElement("input");
		btnclose.id = "btnclose";
		btnclose.type = "button";
		btnclose.style.cssText = "cursor:pointer;width:80px;height:30px;color:black;";
		btnclose.style.backgroundImage = "url(" + this.config.closeBtnImg + ")";
		btnclose.value = "\u5173  \u95ed";
		btnclose.onclick = function() {
			win.closeClick();
		};
		this.getWindow().document.getElementById("diloag")
				.appendChild(btnclose);
	},
	addMsgContent : function() {
		var divcontent = this.getWindow().document.createElement("div");
		divcontent.id = "divcontent";
		divcontent.style.cssText = "width:100%;text-align:center;";
		this.getWindow().document.getElementById("diloag").appendChild(
				divcontent);
	},
	okClick : function() {
	},
	closeClick : function() {
		win.showTags();
		this.getWindow().document.body.removeChild(this.getWindow().document
				.getElementById("diloag"));
		this.getWindow().document.body.removeChild(this.getWindow().document
				.getElementById("backDiv"));
		if (parent) {
			parent.win.showTags();
		}
		if (parent.frames) {
			for ( var i = 0; i < parent.frames.length; i++) {
				try {
					if (parent.frames[i].win) {
						parent.frames[i].win.showTags();
					}
				} catch (e) {

				}
			}
		}
		try {
			this.getWindow().document.body
					.removeChild(this.getWindow().document
							.getElementById("sound"));
		} catch (err) {
		}
		win.config.currentWindow.focus();
		if (win.config.jalert.closeCallBack) {
			win.config.jalert.closeCallBack();
			win.config.jalert.closeCallBack = null;
		}
		win.ok = void (0);
	},
	setCenter : function(objdiv) {
		var objLeft = parseInt(this.getWindow().document.body.scrollLeft
				+ this.getWindow().document.body.clientWidth
				- objdiv.offsetWidth)
				/ 2 + "px";
		var workWindowHeight = this.getWindow().document.body.clientHeight;
		if (workWindowHeight > screen.availHeight) {
			workWindowHeight = screen.availHeight - (41 + 120);
		}// screen.availHeight
		var objTop = parseInt((workWindowHeight - objdiv.offsetHeight) / 2)
				+ this.getScrollTop() + "px";
		objdiv.style.top = objTop;
		objdiv.style.left = objLeft;
	},
	fix : function(objdiv, top, left) {
		if (browser.appName() == "IE" && browser.version() == "6.0") {
			document.documentElement.style.cssText = "background-image:url(about:blank);background-attachment:fixed";
			document.body.style.cssText = "background-image:url(about:blank);background-attachment:fixed";
			objdiv.style.position = "absolute";
			objdiv.style.top = top;
			objdiv.style.left = left;
		} else {
			objdiv.style.cssText = "position:fixed;_position:absolute;top:{0}px;left:{1}px;"
					.format(top, left);
		}
	},
	/***************************************************************************
	 * 取窗口滚动条高度
	 **************************************************************************/
	getScrollTop : function() {
		return document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop
				: document.body.scrollTop;
	},
	/***************************************************************************
	 * 取窗口可视范围的高度
	 **************************************************************************/
	getClientHeight : function() {
		return (document.body.clientHeight && document.documentElement.clientHeight) ? Math
				.min(document.body.clientHeight,
						document.documentElement.clientHeight)
				: Math.max(document.body.clientHeight,
						document.documentElement.clientHeight);
	},

	/***************************************************************************
	 * 取文档内容实际高度
	 **************************************************************************/
	getScrollHeight : function() {
		return Math.max(document.body.scrollHeight,
				document.documentElement.scrollHeight);
	}
};
function jalert(msg, type, title, srcElement) {
	win.addSound();
	// 设置背景控件为false
	win.hiddenTags();
	// 背景层
	win.addBackDiv();
	// 对话框主体
	win.addMsgDiloag();
	// 标题
	win.addTitle(title);
	// 内容
	win.addMsgContent();
	// 关闭按钮 定义未加入
	// 加一行margin-buttom不好使
	// 必须这么加
	/*-----------以上部分全部一致---------------*/
	var typeimg = null;
	switch (type) {
	case "smile":
		win.addRightClose();
		win.addClose();
		typeimg = win.config.smileImg;
		break;
	case "sad":
		win.addRightClose();
		win.addClose();
		typeimg = win.config.sadImg;
		break;
	case "lock":
		typeimg = win.config.lockImg;
		break;
	case "wait":
		typeimg = win.config.waitImg;
		break;
	case "ask":
		win.addRightClose();
		win.addOK();
		win.addClose();
		typeimg = win.config.askImg;
		break;
	case "innerHTML":
		win.addRightClose();
		win.getWindow().document.getElementById("divcontent").innerHTML = msg;
		break;
	case "htmlTag":
		msg.style.display = "block";
		win.addRightClose();
		win.getWindow().document.getElementById("divcontent").appendChild(msg);
		break;
	case "input":
		win.getWindow().document.getElementById("divcontent").innerHTML = "<span class=\"prompt\" id=\"errorJalert\"></span><br/><input value=\""
				+ msg + "\" id=\"txtJalertInput\" type=\"text\"/>";
		break;
	}
	if (msg && typeimg) {
		win.getWindow().document.getElementById("divcontent").innerHTML = "<br/>"
				+ "<img align=\"absMiddle\" src='"
				+ typeimg
				+ "'>&nbsp;&nbsp;"
				+ msg;
	}
	win.hiddenOrShowTag("select", true, win.getWindow().document
			.getElementById("divcontent"));
	win.setCenter(win.getWindow().document.getElementById("diloag"));// 设置浮动窗口位置
	if (srcElement) {
		win.getWindow().document.getElementById("diloag").style.top = position
				.getAbsoluteTopPosByCtrl(srcElement)
				+ "px";
	}
}
// 对话框中包含url地址则不用传入回调函数，可将函数直接写到页面上//
function jwindow(width, height, title, url, srcElement, cache) {
	// 如果本页中存在div对话框。则先将对话框删除
	try {
		win.closeClick();
	} catch (err) {
	}
	if (cache != false) {
		url += ((url.indexOf("?") == -1 ? "?" : "&") + "t=" + Math.random());
	}
	if (url.indexOf("http://") != 0) {
		url = rootPath + url;
	}
	win.hiddenTags();
	if (srcElement) {
		win.config.toTopHeight = position.getAbsoluteTopPosByCtrl(srcElement)
				- height / 2;
	}
	// 背景层
	win.addBackDiv();
	win.addPanel(width, height, title, url);
	win.setCenter(win.getWindow().document.getElementById("diloag"));// 设置浮动窗口位置
}
function jbox(width, height, title, content, initialize) {
	win.hiddenTags();
	// 背景层
	win.addBackDiv();
	win.addPanel(width, height, title);
	win.getWindow().document.getElementById("panelcontent").innerHTML = content;
	if (initialize) {
		initialize();
	}
	win.setCenter(win.getWindow().document.getElementById("diloag"));// 设置浮动窗口位置
}
/*-------------------------提示信息-------------------------------------------*/
function Message(obj) {
			this.obj = obj,
			this._opacity = 0,
			this._showit = null,
			this._hiddenit = null,
			this.config = {
				autoHidden : true,
				delaySecond : 5
			},
			this.show = function(content, srcElement) {
				var divmsg = $(this.obj + "_divmsg");
				if (divmsg) {
					divmsg.parentNode.removeChild(divmsg);
					window.clearInterval(this._showit);
					window.clearInterval(this._hiddenit);
					this._opacity = 0;
				}
				divmsg = $c("div");
				divmsg.id = this.obj + "_divmsg";
				divmsg.style.cssText = "position:absolute;background-color:#f4f8f9;width:auto;padding:10px";
				divmsg.innerHTML = content;
				setOpacity(divmsg, 0);
				document.body.appendChild(divmsg);
				m._showit = window.setInterval(this.obj + ".showIt()", 100);

				// 如果有事件源传递过来说明需要在事件触发源处显示提示信息
				if (srcElement) {
					divmsg.style.top = position
							.getAbsoluteTopPosByCtrl(srcElement)
							- divmsg.offsetHeight + "px";
					divmsg.style.left = position
							.getAbsoluteLeftPosByCtrl(srcElement)
							- (divmsg.offsetWidth - srcElement.offsetWidth)
							/ 2
							+ "px";
				} else {
					win.setCenter(divmsg);
				}
			}, this.showIt = function() {
				var divmsg = $(this.obj + "_divmsg");
				if (this._opacity < 100) {
					this._opacity += 5;
					if (divmsg) {
						setOpacity(divmsg, this._opacity);
					} else {
						window.clearInterval(this._showit);
					}
				} else {
					if (this.config.autoHidden) {
						window.setTimeout(this.obj + ".hidden();",
								this.config.delaySecond * 1000);
					}
					window.clearInterval(this._showit);
				}
			}, this.clearIt = function() {
				divmsg = $(this.obj + "_divmsg");
				if (this._opacity != 0) {
					if (divmsg) {
						this._opacity -= 5;
						setOpacity(divmsg, this._opacity);
					} else {
						window.clearInterval(this._hiddenit);
					}
				} else {
					window.clearInterval(this._hiddenit);
					if (divmsg)
						divmsg.parentNode.removeChild(divmsg);
				}
			}, this.hidden = function() {
				this._hiddenit = window.setInterval(this.obj + ".clearIt();",
						50);
			};
}

// 类搜索框提示信息
function Toolip(obj) {
	this.config = // 提示框显示需要的常量配置
	{
		toolipDiv : null, // 显示提示框的DIV
		showFullName : true, // 是否显示全名称
		descIdHidden : null, // 保存ID的隐藏控件
		descSelectList : null, // 保存item的select控件
		srcElement : null, // 事件源控件保存选中的提示结果
		width : 300, // 提示框显示宽度
		maxLength : 5
	// 允许输入的最大长度
	};

	/*----------------提示框显示需要的变量--------------------*/
	this.obj = obj; // 当前对象引用需要与定义的对象同名
	this.currentIndex = -1; // 当前显示的索引
	this.listCount = 0; // 需要显示的列表所有个数
	this.keyCode = 0; // 当前显示
	this.listArray = new Array(); // 需要显示的内容列表 列表项(uuid,name,fullName)
}
Toolip.prototype.init = function() {
	if (typeof (this.config.toolipDiv) == "string") {
		this.config.toolipDiv = $(this.config.toolipDiv);
	}
	if (typeof (this.config.descIdHidden) == "string") {
		this.config.descIdHidden = $(this.config.descIdHidden);
	}
	if (typeof (this.config.srcElement) == "string") {
		this.config.srcElement = $(this.config.srcElement);
	}
	if (typeof (this.config.descSelectList) == "string") {
		this.config.descSelectList = $(this.config.descSelectList);
	}
	this.config.toolipDiv = $c("div");
	document.body.appendChild(this.config.toolipDiv);
	var left = position.getAbsoluteLeftPosByCtrl(this.config.srcElement);
	var top = position.getAbsoluteTopPosByCtrl(this.config.srcElement)
			+ this.config.srcElement.clientHeight - 1;
	this.config.toolipDiv.style.cssText = "text-align:left;display:none;background:#ffffff;border:#ccc 1px solid;position:absolute;width:"
			+ this.config.width + "px;left:" + left + "px;top:" + top + "px;";

	this.config.toolipDiv.onmouseover = function(e) {
		jevent.cancelBubble(e);
	};
	this.config.toolipDiv.onclick = function(e) {
		jevent.cancelBubble(e);
	};
	// 由于原控件可能会有此事件，为在原控件基础上附加方法，故写成如下方式
	// 示例代码onfocus='v.showMessage(studentInfo.txtClass);'
	// onblur='v.isNull(studentInfo.txtClass);
	var htmlEvents = "jevent.add(" + this.obj + ".config.srcElement"
			+ ",'onkeyup',function(e){" + this.obj + ".show(e);});jevent.add("
			+ this.obj + ".config.srcElement" + ",'onblur',function(){if("
			+ this.obj + ".config.descIdHidden.value==''){" + this.obj
			+ ".config.srcElement.value='';}});";
	window.setTimeout(htmlEvents, 0);
};
Toolip.prototype.prepare = function() {
	alert("请实现该函数以准备提示框数据列表");
};
Toolip.prototype.prepareCallBack = function() {
	if (this.listArray === null || this.listArray.length === 0) {
		this.config.toolipDiv.innerHTML = "没有检查到相关内容...";
	} else {
		var content = new Array();
		content
				.push("<ul style=\"padding:0px;height:auto;margin:3px;list-style:none;width:"
						+ (this.config.width - 4) + "px;\">");
		this.listCount = this.listArray.length;
		for ( var i = 0; i < this.listArray.length; i++) {
			if (this.listArray[i]) {
				content
						.push("<li  title='"
								+ this.listArray[i][2]
								+ "' id=\"item"
								+ i
								+ "\" onmouseover=\"mouse.over(this);\" onmouseout=\"mouse.out(this);\" style=\"cursor:pointer;padding:5px;width:"
								+ (this.config.width - 10)
								+ "px;line-height:30px;border-bottom:#ccc 1px dotted;\" onclick=\""
								+ this.obj + ".showItem(" + i + ");\">");
				content.push(this.listArray[i][2]);
				content.push("</li>");
			}
		}
		content.push("</ul>");
		this.config.toolipDiv.innerHTML = content.join("");

	}
	this.config.toolipDiv.style.display = "block";
};
Toolip.prototype.show = function(e) {
	e = e || window.event;
	this.keyCode = e.keyCode;
	if (this.config.srcElement.value.trim().length > 0) {
		if (this.keyCode == 13) {
			this.appendToItemList();
			this.config.toolipDiv.style.display = "none";
			this.currentIndex = -1;
			this.listCount = 0;
			if (this.config.descIdHidden.value.trim() == "") {
				var currentLi = $("item0");
				if (currentLi) {
					var currentItem = this.listArray[0];
					this.config.descIdHidden.value = currentItem[0];
					this.config.srcElement.value = this.config.showFullName == true ? currentItem[2]
							: currentItem[1];
					if (this.selectedCallBack) {
						this.selectedCallBack(currentItem);
					}
				}
			}
		} else if (this.keyCode == 38 || this.keyCode == 40) {
			this.upAndDown();
		} else if ((this.keyCode == 8 || this.keyCode == 46)
				&& this.config.srcElement.value.length > this.config.maxLength) {
			this.config.srcElement.value = "";
			this.config.descIdHidden.value = "";
		} else {
			this.prepare();
		}
	} else {
		this.config.toolipDiv.style.display = "none";
		this.currentIndex = -1;
		this.listCount = 0;
		this.config.descIdHidden.value = "";
	}
};
Toolip.prototype.showItem = function(itemIndex) {
	var item = this.listArray[itemIndex];
	this.config.descIdHidden.value = item[0];
	this.config.srcElement.value = this.config.showFullName === true ? item[2]
			: item[1];
	this.currentIndex = itemIndex;
	this.config.srcElement.focus();
	this.config.toolipDiv.style.display = "none";
	if (this.selectedCallBack) {
		this.selectedCallBack(item);
	}
};
Toolip.prototype.upAndDown = function() {
	if (this.keyCode == 38) {
		if (this.currentIndex !== 0) {
			this.currentIndex--;
		} else {
			this.currentIndex = this.listCount - 1;
		}
	} else {
		if (this.currentIndex != this.listCount - 1) {
			this.currentIndex++;
		} else {
			this.currentIndex = 0;
		}
	}
	if (this.currentIndex > this.listCount || this.currentIndex < 0) {
		this.currentIndex = 0;
	}
	var currentLi = $("item" + this.currentIndex);
	var currentItem = this.listArray[this.currentIndex];
	this.config.descIdHidden.value = currentItem[0];
	this.config.srcElement.value = this.config.showFullName == true ? currentItem[2]
			: currentItem[1];
	if (this.selectedCallBack) {
		this.selectedCallBack(currentItem);
	}
	for ( var i = 0; i < this.listCount; i++) {
		if ($("item" + i)) {
			$("item" + i).style.backgroundColor = "#ffffff";
			$("item" + i).style.fontWeight = "normal";
		}
	}
	currentLi.style.backgroundColor = "#FF99FF";
	currentLi.style.fontWeight = "bold";
};
Toolip.prototype.hidden = function() {
	if (this.config.toolipDiv) {
		this.config.toolipDiv.style.display = "none";
	}
};
Toolip.prototype.appendToItemList = function() {
	if (this.config.descSelectList
			&& this.config.srcElement.value.trim() !== "") {
		sl.add(this.config.srcElement.value, this.config.descIdHidden.value,
				this.config.descSelectList);
		this.config.srcElement.value = "";
	}
};

// 菜单
/*
 * 标签tag.js应用实例
 */
function Menu(obj) {
	this.config = // 菜单显示需要的常量配置
	{
		frameDiv : null, // 菜单提示框的DIV
		srcElement : null, // 事件源控件保存选中的提示结果
		width : 300, // 提示框显示宽度
		menuList : null, // 菜单数组
		position : 'lb', // 位置默认左下角
		container : null, // 容器
		parent : null, // 父菜单
		childs : new Array(), // 子菜单
		brothers : new Array()
	// 兄弟节点
	};
	this.obj = obj;
	this.LEFT_BOTTOM = "lb";
	this.TOP_RIGHT = "tr";
};
Menu.prototype.init = function() {
	this.config.frameDiv = $c("div");
	this.config.frameDiv.onmouseover = jevent.cancelBubble;
	document.body.appendChild(this.config.frameDiv);
	this.config.frameDiv.style.cssText = cssText.menuFrameDiv.format(
			this.config.width, 0, 0);
	var menuHTML = new Array();
	menuHTML.push('<ul style="{0}">'.format(cssText.menuUl
			.format(this.config.width - 2)));
	for ( var i = 0; i < this.config.menuList.length; i++) {
		menuHTML
				.push('<li style="{0}" {3}><a href="javascript:void(0);" onclick="{1}.itemClick({2});"  style="width:{4}px;display:line-block;cursor:pointer"><span style="float:left">{5}</span><span  style="float:right;">{6}</span></a></li>'
						.format(
								cssText.menuLi.format(this.config.width),
								this.obj,
								i,
								this.config.menuList[i].more ? 'onmouseover="{0}.itemMore(this,{1});"'
										.format(this.obj, i)
										: '', this.config.width,
								this.config.menuList[i].text,
								this.config.menuList[i].more ? ">>" : ""));
	}
	menuHTML.push('</ul>');
	this.config.frameDiv.innerHTML = menuHTML.join("");
};
Menu.prototype.itemClick = function(index) {
	alert("click:" + this.config.menuList[index].text);
};
Menu.prototype.itemMore = function(srcElement, index) {
	alert("more:" + this.config.menuList[index].text);
};
Menu.prototype.show = function(srcElement, parentMenu) {
	this.config.parent = parentMenu;
	this.config.srcElement = srcElement;
	var scrollTop = 0;
	if (this.config.container)
		scrollTop = this.config.container.scrollTop;
	var left = position.getAbsoluteLeftPosByCtrl(this.config.srcElement);
	if (this.config.position == this.TOP_RIGHT) {
		left += this.config.srcElement.offsetWidth;
	}
	var top = position.getAbsoluteTopPosByCtrl(this.config.srcElement)
			- scrollTop;
	if (this.config.position == this.LEFT_BOTTOM) {
		top += this.config.srcElement.offsetHeight;
	}
	this.config.frameDiv.style.left = left;
	this.config.frameDiv.style.top = top - 2;
	this.config.frameDiv.style.display = "block";
	// 显示菜单同时隐藏子菜单
	for ( var i = 0; i < this.config.childs.length; i++) {
		this.config.childs[i].hidden();
	}
	// 隐藏兄弟菜单
	for ( var i = 0; i < this.config.brothers.length; i++) {
		this.config.brothers[i].hidden();
	}
};
Menu.prototype.hidden = function() {
	if (this.config.frameDiv) {
		this.config.frameDiv.style.display = "none";
		// 隐藏其子菜单
		for ( var i = 0; i < this.config.childs.length; i++) {
			this.config.childs[i].hidden();
		}
	}
};
Menu.prototype.dispose = function() {
	if (this.config.frameDiv) {
		document.body.removeChild(this.config.frameDiv);
	}
};